package com.itheima.d3_annotation;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.Arrays;

public class Annotation2 {
    @Test
    public void parseClass(){
        Class c = Demo.class;

        if(c.isAnnotationPresent(MyTest2.class)){
            MyTest2 myTest2
                    = (MyTest2) c.getDeclaredAnnotation(MyTest2.class);
            System.out.println(myTest2.value());
            System.out.println(myTest2.aaa());
            System.out.println(Arrays.toString(myTest2.bbb()));
        }
    }

    @Test
    public void parseMethod() throws Exception {
        Class c = Demo.class;
        Method m = c.getDeclaredMethod("test1");

        if(m.isAnnotationPresent(MyTest2.class)){
            MyTest2 myTest2
                    = (MyTest2) m.getDeclaredAnnotation(MyTest2.class);
            System.out.println(myTest2.value());
            System.out.println(myTest2.aaa());
            System.out.println(Arrays.toString(myTest2.bbb()));
        }
    }
}
